package com.t.animal;

public abstract class Animal {
    public String name;
    public int age;
    public Animal(){
        System.out.println("Animals类被调用");
    }
    public abstract void eat();
    public abstract void sleep();
}
class Dog extends Animal{
    public Dog(){
        System.out.println("Dog类已被调用");
    }
    @Override
    public void eat(){
        System.out.println(name+":该动物喜欢吃骨头");
    }
    @Override
    public void sleep(){
        System.out.println(name+":必须要覆写该动物的sleep方法");
    }
}
class Cat extends Animal{
    public Cat(){
        System.out.println("Cat类已被调用");
    }
    @Override
    public void eat(){
        System.out.println(name+":该动物喜欢吃鱼");
    }

    @Override
    public void sleep() {
        System.out.println(name+":必须要覆写该动物的sleep方法");
    }
}
class Snail extends Animal{
    public Snail(){
        System.out.println("Snail类已被调用");
    }
    @Override
    public void eat(){
        System.out.println(name+":该动物喜欢吃蔬菜");
    }

    @Override
    public void sleep() {
        System.out.println(name+":必须要覆写该动物的sleep方法");
    }
}
